package corp.edu.amadeus.core.bluetooth.sender.helper;

import org.apache.log4j.Logger;
import corp.edu.amadeus.core.bluetooth.sender.ifc.ISender;
import corp.edu.amadeus.core.bluetooth.sender.impl.OBEXSender;

public class ContentSender {

	private static Logger log = Logger.getLogger(ContentSender.class);
	private ContentAccessHelper content_helper = null;

	public ContentSender() {
		this.content_helper = new ContentAccessHelper();
	}

	public void sendContent(String url,  byte[] content,
			String contentName) throws Exception {
		log.debug("Sending content. . . . to " + url);
		String protocol = "", contentType = "";
		contentType = this.content_helper.getContentType(contentName);
		ISender sender = null;
		int index= url.indexOf(':');
		protocol= url.substring(0, index);
		if("btgoep".equals(protocol)) {
			sender = new OBEXSender();
			log.debug("Lanzando envio OBEX url-dispositivo " +
				url);
			sender.send(url, content, contentType, contentName);
		}
	}
}